		TITLE	DECLSEGS - Copyright (c) SLR Systems 1990

		INCLUDE MACROS
		INCLUDE	SECTS

if	any_overlays

		PUBLIC	DECLARE_OVERLAY_SEGMENTS

		.DATA

	SOFT	EXTB	RELOAD_BYTE,SEG_COMBINE

	SOFT	EXTD	$$SLR$$_PTR,$$SLR_VECTORS_PTR,$$SLR_SECTIONS_PTR,$$SLR_CODE_PTR,$$SLR_TABLE_PTR,FIRST_MODULE,SLR_CODE_CLASS
	SOFT	EXTD	SEG_NAME,SEG_LEN,SEG_CLASS_NAME,CURNMOD,SLR_HDR_TABLE,SLR_CODE,SLR_SECTIONS,SLR_RELOAD_STACK,SLR_VECTORS
	SOFT	EXTD	$$SLR_SCODE_PTR,SLR_SCODE_CLASS,$$SLR_FNAMES_PTR,SLR_FNAMES

		.CODE	PASS1_TEXT

	SOFT	EXTP	DEFINE_SEGMOD

		ASSUME	DS:NOTHING

DECLARE_OVERLAY_SEGMENTS	PROC
		;
		;DECLARE SEGMENTS HERE SO THEY GET ORDERED
		;
		FIXDS
		FIXES
		LEA	SI,FIRST_MODULE
		LEA	DI,CURNMOD
		MOVSW
		MOVSW

		LEA	SI,$$SLR_CODE_PTR
		LEA	DI,SEG_CLASS_NAME
		MOVSW
		MOVSW
		;
		XOR	AX,AX
		MOV	SEG_LEN.LW,(SIZE SLRCODE_STRUCT+15)/16 * 16
		MOV	SEG_LEN.HW,AX
		MOV	WPTR SEG_COMBINE,SA_PARA*256+SC_COMMON
		LEA	SI,$$SLR_TABLE_PTR
		LEA	DI,SEG_NAME
		MOVSW
		MOVSW
		CALL	DEFINE_SEGMOD		;$$SLR_CODE:$$SLR_TABLE
		FIXDS
		FIXES
		MOV	SLR_HDR_TABLE.OFFS,BX
		MOV	SLR_HDR_TABLE.SEGM,AX

		MOV	SEG_LEN.LW,0
		MOV	WPTR SEG_COMBINE,SA_PARA*256+SC_COMMON
		LEA	SI,$$SLR_FNAMES_PTR
		LEA	DI,SEG_NAME
		MOVSW
		MOVSW
		CALL	DEFINE_SEGMOD		;$$SLR_CODE:$$SLR_TABLE
		FIXDS
		FIXES
		MOV	SLR_FNAMES.OFFS,BX
		MOV	SLR_FNAMES.SEGM,AX

		MOV	SEG_LEN.LW,0
		MOV	WPTR SEG_COMBINE,SA_PARA*256+SC_PUBLIC	;PARA PUBLIC

		LEA	SI,$$SLR_CODE_PTR		;PLACE FOR OVERLAY HANDLER CODE
		LEA	DI,SEG_NAME
		MOVSW
		MOVSW
		CALL	DEFINE_SEGMOD		;$$SLR_CODE:$$SLR_CODE
		FIXDS
		FIXES
		MOV	SLR_CODE.OFFS,BX
		MOV	SLR_CODE.SEGM,AX

		LEA	SI,$$SLR_SECTIONS_PTR		;PLACE FOR SECTION TABLE
		LEA	DI,SEG_NAME
		MOVSW
		MOVSW
		LEA	SI,$$SLR_SCODE_PTR
		LEA	DI,SEG_CLASS_NAME
		MOVSW
		MOVSW
		CALL	DEFINE_SEGMOD		;$$SLR_SECTIONS:$$SLR_SECTIONS
		FIXDS
		MOV	SLR_SECTIONS.OFFS,BX
		MOV	SLR_SECTIONS.SEGM,AX
		CMP	RELOAD_BYTE,'N'
		JZ	2$

		CALL	DEFINE_SEGMOD			;PLACE FOR RELOAD STACK
		FIXDS
		MOV	SLR_RELOAD_STACK.OFFS,BX
		MOV	SLR_RELOAD_STACK.SEGM,AX

2$:
		FIXES
		LEA	SI,$$SLR$$_PTR
		LEA	DI,SEG_CLASS_NAME
		MOVSW
		MOVSW
		LEA	SI,$$SLR_VECTORS_PTR		;PLACE FOR VECTOR TABLE
		LEA	DI,SEG_NAME
		MOVSW
		MOVSW
		;
		CALL	DEFINE_SEGMOD		;AX:BX IS SEGMOD, DX IS PHYS
		FIXDS
		MOV	SLR_VECTORS.OFFS,BX
		MOV	SLR_VECTORS.SEGM,AX
		MOV	CURNMOD.SEGM,0

		LDS	SI,SLR_CODE
		ASSUME	DS:NOTHING
		SYM_CONV_DS
		LDS	SI,[SI]._SM_BASE_SEG
		SYM_CONV_DS
		FIXES
		LEA	SI,[SI]._SEG_CLASS
		LEA	DI,SLR_CODE_CLASS
		MOVSW
		MOVSW

		LDS	SI,SLR_SECTIONS
		SYM_CONV_DS
		LDS	SI,[SI]._SM_BASE_SEG
		SYM_CONV_DS
		LEA	SI,[SI]._SEG_CLASS
		LEA	DI,SLR_SCODE_CLASS
		MOVSW
		MOVSW

		FIXDS
		RET

DECLARE_OVERLAY_SEGMENTS	ENDP

endif

		END

